﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Projeto3D
{
    class Inimigo : Object3D
    {
        Vector3 direction;

        public Inimigo(Model inimigo)
            : base(inimigo)
        {
            this.position = new Vector3(20, 1, 0);
            this.direction = new Vector3();
        }

        public void update(Vector3 charPosition)
        {
            direction = new Vector3(charPosition.X - this.position.X, charPosition.Y - this.position.Y, charPosition.Z - this.position.Z);
            direction.Normalize();
            direction = direction / 10;

            this.rotacao = new Vector3(this.rotacao.X, MathHelper.ToDegrees((float)((-1) * Math.Atan2(direction.Z, direction.X))) + 90, this.rotacao.Z);

            this.position += direction;
        }

        public void update()
        {
            this.position -= direction;
            this.rotacao = new Vector3(this.rotacao.X, MathHelper.ToDegrees((float)((-1) * Math.Atan2(direction.Z, direction.X))) - 90, this.rotacao.Z);
        }
    }
}
